//
//  DWAnimationViewController.m
//  OCAPPDemo
//
//  Created by OS on 2023/1/10.
//

#import "DWAnimationViewController.h"
#import "DWMaskViewController.h"

@interface DWAnimationViewController ()

@property (weak, nonatomic) IBOutlet UIView *redView;

@end

@implementation DWAnimationViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"Animation";
}

- (IBAction)mask:(id)sender {
    DWMaskViewController *maskVC = [[DWMaskViewController alloc] init];
    [self.navigationController pushViewController:maskVC animated:YES];
}

- (IBAction)left:(id)sender {
    [self performAnimations:kCATransitionFromLeft];
}

- (IBAction)right:(id)sender {
    [self performAnimations:kCATransitionFromRight];
}

- (IBAction)top:(id)sender {
    [self performAnimations:kCATransitionFromTop];
}

- (IBAction)bottom:(id)sender {
    [self performAnimations:kCATransitionFromBottom];
}

- (void)performAnimations:(NSString *)transition{
    CATransition *catransition = [CATransition animation];
    catransition.duration = 0.5;
    [catransition setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]];
    catransition.type = kCATransitionPush; //choose your animation
    catransition.subtype = transition;
    [self.redView.layer addAnimation:catransition forKey:nil];
}



@end
